package com.wqtz.chechai.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.orhanobut.logger.Logger;
import com.wqtz.chechai.bean.Car;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2017/1/19 10:07
 */

public class WQTZViewPager extends ViewPager {
	private float mDownX;
	private float mDowny;

	public WQTZViewPager(Context context) {
		super(context);
	}

	public WQTZViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}


	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
			case MotionEvent.ACTION_DOWN: {
				mDownX = ev.getX();
				mDowny = ev.getY();
				getParent().requestDisallowInterceptTouchEvent(true);
			}
			break;

			case MotionEvent.ACTION_MOVE: {
				if (Math.abs(ev.getX() - mDownX) > 1000) { //先禁止ViewPager滑动
					return true;
				} else  {
					return false;
				}
			}
		}
		return super.onInterceptTouchEvent(ev);
	}
}